package com.eleme.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.eleme.entity.Bussiness;
import com.eleme.service.NormalService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;




/**
 * Servlet implementation class ShopMian
 */
public class ShopMain extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		List<Bussiness> li= new NormalService().findparentname();
		response.setContentType("text/html;charset=utf-8");
		response.getWriter().print(new GsonBuilder().create().toJson(li));
		
//		System.out.println(li);
//		request.setAttribute("data", li);
//		request.getRequestDispatcher("/pages/mainpages/mainpages.jsp").forward(request, response);
	}

}
